package util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import form.ActionForm;

public class FullForm {
	public FullForm(){}
	public static ActionForm full(String formpath,HttpServletRequest request){
		ActionForm form = null;
		try{
			Class  clazz = Class.forName(formpath);//通过页面名称,反射获取页面class
			form = (ActionForm) clazz.newInstance();//实例化该form
			Field [] fa = clazz.getDeclaredFields();//获取该form的所有方法属性
			for(Field f:fa){
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));//将实例化的form和类名装载
				f.setAccessible(false);
			}
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("警告:form装载error");
		}
		return form;
	}
}
